namespace YXShop.ExcelLite
{
    using System;

    public sealed class ExcelColumn : ExcelColumnRowBase
    {
        private CellRange cells;
        private bool hidden;
        private int width;

        internal ExcelColumn(ExcelColumnCollection parent, int index) : base(parent, index)
        {
            this.width = -1;
        }

        internal ExcelColumn(ExcelColumnCollection parent, ExcelColumn sourceColumn) : base(parent, sourceColumn)
        {
            this.width = -1;
            this.width = sourceColumn.width;
            this.hidden = sourceColumn.hidden;
        }

        public CellRange Cells
        {
            get
            {
                if (this.cells == null)
                {
                    this.cells = new CellRange(base.Parent.Parent, 0, base.Index, 0xffff, base.Index);
                }
                return this.cells;
            }
        }

        public bool Hidden
        {
            get
            {
                return this.hidden;
            }
            set
            {
                this.hidden = value;
            }
        }

        public int Width
        {
            get
            {
                if (this.width != -1)
                {
                    return this.width;
                }
                return base.Parent.Parent.DefaultColumnWidth;
            }
            set
            {
                this.width = value;
            }
        }
    }
}

